$(function(){
	$('#dialog').dialog();
	$(".easyui-accordion ul li a").click(function(){
												   var tabTitle = $(this).text();
													var url = $(this).attr("href");
													var target=$(this).attr("target");
													
													addTab(tabTitle,url,target);
												});
		$('.easyui-accordion li a').click(function(){
			var tabTitle = $(this).text();
			var url = $(this).attr("href");
			//addTab(tabTitle,url);
			$('.easyui-accordion li div').removeClass("selected");
			$(this).parent().addClass("selected");
		}).hover(function(){
			$(this).parent().addClass("hover");
		},function(){
			$(this).parent().removeClass("hover");
		});
	});
	
	function addTab(subtitle,url,target){
	
	if(!$('#tabs').tabs('exists',subtitle)){
		$('#tabs').tabs('add',{
			title:subtitle,
			content:createFrame(url,target),
			closable:true,
			width:$('#mainPanle').width()-10,
			height:$('#mainPanle').height()-26
		});
	}else{
		$('#tabs').tabs('select',subtitle);
	}

	
}

function createFrame(url,target)
{
	var s = '<iframe name="'+target+'" scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
	
	return s;
}
//修改密码
function modifyPassword()
{
	var id=$("#id").val();
	var oldPassword=$.trim($("#oldPassword").val());
	var password=$.trim($("#password").val());
	var password2=$.trim($("#password2").val());
	if(oldPassword.length<6||oldPassword.length>30)
	{
		alert("原始密码长度错误，在6~30");
		return false;
	}
	if(password.length<6||password.length>30)
	{
		alert("新密码长度错误，在6~30");
	   return false;
	}
	if(password2!=password)
	{
		alert("两次输入新密码不一致");
	   return false;
	}
	$.getJSON("user!modifyUser.action",{"user.id":id,"user.password":password+","+oldPassword},function(data){
		if(data.info=="OldERROR")
		{
			alert("原始密码不对!");
		}else if(data.info)
		{
			alert("修改成功!");
			$('#dialog').dialog('close');
		}else
		{
			alert("修改失败!");
		}
	});
}
